package we.socialcontroller.zingme;

import java.util.ArrayList;
import java.util.List;

import we.config.CConfigHandler;

import we.socialcontroller.ISocialController;
import we.socialcontroller.ISocialController;
import we.socialcontroller.CSocialController;
import we.socialcontroller.CSocialController;
import we.socialcontroller.CSocialControllerException;
import we.socialcontroller.CSocialUserInfo;


public class ZM_SocialController implements ISocialController {
    private ZM_Config config;

    public ZM_SocialController() {
        super();

        config = new ZM_Config();
        config.apiURL = CConfigHandler.instance().get("zm_api_url");
        config.apiKey = CConfigHandler.instance().get("zm_api_key");
        config.secret = CConfigHandler.instance().get("zm_api_secret");
        config.timeout = 30;
    }

    public long getLoggedInUser(String sessionKey) throws CSocialControllerException {
        ZM_Session zmSession = new ZM_Session(config);
        return zmSession.getLoggedInUser(sessionKey);
    }

    public CSocialUserInfo getUserInfo(Long userId) throws CSocialControllerException {
        ZM_User zmUser = new ZM_User(config);
        return zmUser.getUserInfo(userId);
    }

    public List<Long> getFriendList(String sessionId) throws CSocialControllerException {
        ZM_Friends zmFriend = new ZM_Friends(config);
        return zmFriend.getFriendList(sessionId);
    }

    public List<CSocialUserInfo> getUserInfo(List<Long> userId) throws CSocialControllerException {
        List<CSocialUserInfo> list = new ArrayList<CSocialUserInfo>();
        for (Long s : userId) {
            list.add(getUserInfo(s));
        }
        return list;
    }

    public static void main(String[] args) {
        long id;
        System.out.println(" bat dau ");
        try {
            id =
 CSocialController.GetController().getLoggedInUser("1F0189885B30ED5D7AD9E530");
            System.out.println(id);
        } catch (CSocialControllerException e) {
            e.printStackTrace();
        }
        System.out.println(" ket thuc ");
    }
}
